﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using Interfaces.Update_Interfaces;
using Interfaces.General_Interfaces;
using Interfaces.Information_Interfaces;
using Views.Status_Views;
using Model.Query_Model;
using Presenters.Update_Presenters;


namespace Views.Update_Views
{
    public partial class RoadUpdateView : Form, IRoadUpdateView
    {
        RoadUpdatePresenter presenter = null;

        public RoadUpdateView()
        {
            InitializeComponent();
            presenter = new RoadUpdatePresenter(this);
        }

        protected override void OnLoad(EventArgs e)
        {
            presenter.SendDataToView();
            base.OnLoad(e);
        }

        string IRoadUpdateView.fromCity
        {
            get
            {
                return fromCity.Text;
            }
            set
            {
                fromCity.Text = value as string;
            }
        }

        string IRoadUpdateView.fromCountry
        {
            get
            {
                return fromCountry.Text;
            }
            set
            {
                fromCountry.Text = value as string;
            }
        }

        string IRoadUpdateView.toCity
        {
            get
            {
                return toCity.Text;
            }
            set
            {
                toCity.Text = value as string;
            }
        }

        string IRoadUpdateView.toCountry
        {
            get
            {
                return toCuntry.Text;
            }
            set
            {
                toCuntry.Text = value as string;
            }
        }

        Model.Query_Model.TypeRoadOutput IRoadUpdateView.typeRoad
        {
            get
            {
                return (TypeRoadOutput)type.SelectedItem;
            }
            set
            {
                type.SelectedItem = value;
            }
        }

        IList<Model.Query_Model.TypeRoadOutput> IRoadUpdateView.typeRoadList
        {
            get
            {
                return (List<TypeRoadOutput>)type.DataSource;
            }
            set
            {
                type.DataSource = value as List<TypeRoadOutput>;
            }
        }

        T Interfaces.Inherited_Interfaces.IView.ReturnView<T>()
        {
            return ((T)(object)this);
        }

        void Interfaces.Inherited_Interfaces.IError.ShowError()
        {
            presenter.ShowError(new ErrorView());
        }

        void Interfaces.Inherited_Interfaces.ISuccess.ShowSuccess()
        {
            presenter.ShowSuccess(new SuccessView());
        }

        void IParamable.SetParams(params object[] param)
        {
            presenter.road = (RoadOutput)param.Where(x => x.GetType() == typeof(RoadOutput)).Take(1).FirstOrDefault();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            presenter.Update();
        }
    }
}
